package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotGuestCheckin;
import com.gaohe.hotal.service.IHotGuestCheckinService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户入住Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/checkin")
public class HotGuestCheckinController extends BaseController
{
    @Autowired
    private IHotGuestCheckinService hotGuestCheckinService;

    /**
     * 查询客户入住列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:checkin:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotGuestCheckin hotGuestCheckin)
    {
        startPage();
        List<HotGuestCheckin> list = hotGuestCheckinService.selectHotGuestCheckinList(hotGuestCheckin);
        return getDataTable(list);
    }

    /**
     * 导出客户入住列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:checkin:export')")
    @Log(title = "客户入住", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotGuestCheckin hotGuestCheckin)
    {
        List<HotGuestCheckin> list = hotGuestCheckinService.selectHotGuestCheckinList(hotGuestCheckin);
        ExcelUtil<HotGuestCheckin> util = new ExcelUtil<HotGuestCheckin>(HotGuestCheckin.class);
        util.exportExcel(response, list, "客户入住数据");
    }

    /**
     * 获取客户入住详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:checkin:query')")
    @GetMapping(value = "/{checkinId}")
    public AjaxResult getInfo(@PathVariable("checkinId") Long checkinId)
    {
        return success(hotGuestCheckinService.selectHotGuestCheckinByCheckinId(checkinId));
    }

    /**
     * 新增客户入住
     */
    @PreAuthorize("@ss.hasPermi('hotal:checkin:add')")
    @Log(title = "客户入住", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotGuestCheckin hotGuestCheckin)
    {
        return toAjax(hotGuestCheckinService.insertHotGuestCheckin(hotGuestCheckin));
    }

    /**
     * 修改客户入住
     */
    @PreAuthorize("@ss.hasPermi('hotal:checkin:edit')")
    @Log(title = "客户入住", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotGuestCheckin hotGuestCheckin)
    {
        return toAjax(hotGuestCheckinService.updateHotGuestCheckin(hotGuestCheckin));
    }

    /**
     * 删除客户入住
     */
    @PreAuthorize("@ss.hasPermi('hotal:checkin:remove')")
    @Log(title = "客户入住", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkinIds}")
    public AjaxResult remove(@PathVariable Long[] checkinIds)
    {
        return toAjax(hotGuestCheckinService.deleteHotGuestCheckinByCheckinIds(checkinIds));
    }
}
